var app = new Vue({
    el: "#app",
    data: {
        list: ["长沙", "株洲", "重庆"],
        inputValue: "",
        weatherList: []
    },
    methods: {
        add: function() {
            if (this.inputValue == "") {
                alert("请输入内容");
            } else {
                this.list.push(this.inputValue);
                var that = this;
                axios.get('http://wthrcdn.etouch.cn/weather_mini?city=' + this.inputValue)
                    .then(function(response) {
                        console.log(response);
                        that.weatherList = response.data.data.forecast
                    }, function(err) {
                        console.log(err);
                    })
            }

        },
        remove: function(index) {
            this.list.splice(index, 1);
        },
        history: function(item) {
            var that = this;
            axios.get('http://wthrcdn.etouch.cn/weather_mini?city=' + item)
                .then(function(response) {
                    // console.log(response.data.data.forecast);
                    that.weatherList = response.data.data.forecast
                }, function(err) {
                    console.log(err);
                })
        }
    }
})